<template>
	<view class="container">
		<uni-card title="职位信息" style="margin-top: 0px;">
			<view class="item">职位名称：{{item.name}}</view>
			<view class="item">岗位职责：{{item.obligation}}</view>
			<view class="item">公司地点：{{item.address}}</view>
			<view class="item">薪资待遇：{{item.salary}}</view>
			<view class="item">联系人：{{item.contacts}}</view>
			<view class="item">职位描述：{{item.obligation}}</view>
			<view class="item">工作年限：{{item.need}}</view>
		</uni-card>
		<uni-card title="公司信息" style="margin-top: 10px;">
			<view class="item">公司名称：{{data.companyName}}</view>
			<view class="item">公司简介：{{data.introductory}}</view>
		</uni-card>
		<button type="primary" @click="submit" style="margin-top: 20px;">投简历</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				item: {},
				data: {}
			};
		},
		onLoad(item) {
			this.get('/prod-api/api/job/post/' + item.id, {

			}, ).then(res => {
				let data = res.data
				console.log(data);
				this.item = data
				this.get('/prod-api/api/job/company/' + data.companyId, {

				}, ).then(res => {
					let data = res.data
					this.data = data
				})
			})

		},
		onReady() {

		},
		onShow() {

		},
		methods: {
			submit() {
				this.get('/prod-api/api/job/resume/queryResumeByUserId/' + uni.getStorageSync("user").userId, {

				}, ).then(res => {
					let data = res.data
					// if (!data || data.experience == '' || data.experience == null || data.education == '' || data
					if (!data || data.experience == ''  || data.education == '' 
						// .education == null) {
						) {
						uni.showToast({
							title: '请先完善简历后投递',
							icon: 'none'
						});
						this.getOpenerEventChannel().emit("result", 500)
						uni.navigateBack({
							delta: 1
						});
					} else {
						this.post('/prod-api/api/job/deliver', {
							"companyId": this.item.companyId,
							"companyName": this.data.companyName,
							"money": this.item.salary,
							"postId": this.item.professionId,
							"postName": this.item.professionName,
							"satrTime": "2023-01-01",
							// "userId": uni.getStorageSync("user").userId,
							// "userName": uni.getStorageSync("user").userName
						}, ).then(res => {
							console.log(res);
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
							if (res.code == 200) {
								setTimeout(function() {
									uni.navigateBack({
										delta: 1
									});
								}, 300);
							}

						})
					}
				})
			}
		}
	};
</script>

<style lang="scss">

</style>
